package com.SmartCampus.system.service.impl;

import com.SmartCampus.system.mapper.ScoreMapper;
import com.SmartCampus.system.model.dto.score.ScoreQueryRequest;
import com.SmartCampus.system.model.entity.Score;
import com.SmartCampus.system.model.vo.ScoreVO;
import com.SmartCampus.system.service.ScoreService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author wangliang
* @description 针对表【score(成绩表)】的数据库操作Service实现
* @createDate 2024-12-26 18:54:38
*/
@Service
public class ScoreServiceImpl extends ServiceImpl<ScoreMapper, Score>
    implements ScoreService {

    @Resource
    private ScoreMapper scoreMapper;

    @Override
    public Page<ScoreVO> getScoreByAll(Page<ScoreVO> page, ScoreQueryRequest scoreQueryRequest) {
        List<ScoreVO> scoreVOList = scoreMapper.getScoreByAll(page, scoreQueryRequest);
        if (scoreVOList == null){
            throw new RuntimeException("查询失败，请联系管理员");
        }
        return page.setRecords(scoreVOList);
    }

    @Override
    public Page<ScoreVO> getScoreByMy(Page<ScoreVO> page, ScoreQueryRequest scoreQueryRequest, Long userId) {
        List<ScoreVO> scoreVOList = scoreMapper.getScoreByMy(page, scoreQueryRequest, userId);
        if (scoreVOList == null){
            throw new RuntimeException("查询失败，请联系管理员");
        }
        return page.setRecords(scoreVOList);
    }
}




